package com.nbsaas.boot.controller.shop;

import com.nbsaas.boot.rest.annotations.SearchData;
import com.nbsaas.boot.rest.annotations.UpdateData;
import com.nbsaas.boot.rest.response.ResponseObject;
import com.nbsaas.boot.shop.api.apis.ShopApi;
import com.nbsaas.boot.shop.api.domain.request.ShopRequest;
import com.nbsaas.boot.shop.api.domain.response.ShopResponse;
import com.nbsaas.boot.utils.UserUtils;
import org.apache.shiro.authz.annotation.RequiresAuthentication;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
*  对外控制器
*/
@RequiresAuthentication
@RestController
@RequestMapping("/shop")
public class ShopController {


    @Resource
    private ShopApi shopApi;


   @UpdateData
   @RequestMapping("/update")
   public ResponseObject<ShopResponse> update(@RequestBody ShopRequest request) {
       request.setId(UserUtils.user().getShop());
       return shopApi.update(request);
   }

    @SearchData
    @RequestMapping("/view")
    public ResponseObject<ShopResponse> view(@RequestBody ShopRequest request) {
        request.setId(UserUtils.user().getShop());
        return shopApi.view(request);
    }
}